package com.elitesland.system.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * <pre>发号器规则定义</pre>
 *
 * @author mir
 * @date 2020-10-10
 */

@Entity
@Table(name = "sys_number_rule")
@org.hibernate.annotations.Table(appliesTo = "sys_number_rule", comment = "发号器规则")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "发号器规则", description = "发号器规则")
public class SysNumberRuleDO extends BaseModel implements Serializable {
    private static final long serialVersionUID = -2550818946023069619L;

    @ApiModelProperty(value = "规则编号")
    @Comment("规则编号")
    @Column(nullable = false, unique = true)
    String ruleCode;

    @ApiModelProperty(value = "规则名称")
    @Comment("规则名称")
    @Column(length = 64)
    String ruleName;

    @ApiModelProperty(value = "规则分类码：sys:numrulcls")
    @Comment("规则分类码：sys:numrulcls")
    @Column(length = 32)
    String ruleClass;

    @ApiModelProperty(value = "取号示例")
    @Comment("取号示例")
    @Column()
    String sampleCode;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SysNumberRuleDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SysNumberRuleDO entity = (SysNumberRuleDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}

